//
// Created by 紫霄 on 2020/4/9.
//

#ifndef LEETCODE_09_FIB_H
#define LEETCODE_09_FIB_H
class Solution {
public:
  int fib(int n) {
    int i = 0;
    int j = 1;
    while (n--) {
      j = i + j;
      i = j - i;
      if (i >= 1000000007)
        i -= 1000000007;
      if (j >= 1000000007)
        j -= 1000000007;
    }

    return i;
  }
};
#endif // LEETCODE_09_FIB_H
